#coding=utf8

import os
import sys

from dwarf_scanner import DwarfScanner, T

if __name__ == "__main__":
    fileName = "manuscript.txt"
    if len(sys.argv) > 1:
        fileName = sys.argv[1]
    if not os.path.exists(fileName):
        print "Error: Can't open file '" + fileName + "'"
        sys.exit(1)
    file = open(fileName, 'r')
    scanner = DwarfScanner(file)

    token = scanner.GetNextToken()
    while token.Type() != T.EOF:
        if token.Type() != T.WHITESPACE:
            print(token)
        token = scanner.GetNextToken()